package org.pku_uestc.hackathon.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class PrefUtils {
	
	private static final String PRE_NAME="org.pku_uestc.hackathon";
	
	private static SharedPreferences getSharedPref(Context context) {
		return context.getSharedPreferences(PRE_NAME, Context.MODE_PRIVATE);
	}
	
	public static void putStringValue(Context context, String key, String value) {
		SharedPreferences.Editor editor = getSharedPref(context).edit();
		editor.putString(key, value);
		editor.commit();
	}
	
	public static String getStringValue(Context context, String key, String defaultValue) {
		return getSharedPref(context).getString(key, defaultValue);
	}
	
	public static void putBooleanValue(Context context, String key, boolean value) {
	    SharedPreferences.Editor editor = getSharedPref(context).edit();
	    editor.putBoolean(key, value);
	    editor.commit();
	}
	
	public static boolean getBooleanValue(Context context, String key, boolean defaultValue) {
	    return getSharedPref(context).getBoolean(key, defaultValue);
	}
}
